import 'package:bxultimate/data/request/home_request.dart';
import 'package:get/get.dart';

import 'state.dart';

class ShopActivityListController extends GetxController {
  final ShopActivityListState state = ShopActivityListState();



  var pageSize = 10;

  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();

    getData(false);
  }

  getData(bool isClear) async {
    var list = await HomeRequest.getShopActivity(state.page, pageSize);
    if(isClear){
      state.shopActivityList = list;
    }else{
      state.shopActivityList.addAll(list);
    }
  }

  Future<void> onRefresh() async {
    state.page = 1;
    await getData(true);
  }

  Future<void> onLoad() async {
    state.page++;
    await getData(false);
  }


}
